package io.renren.modules.sys.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import io.renren.common.constant.Code;
import io.renren.common.exception.BizException;
import io.renren.common.utils.ShiroUtils;
import io.renren.modules.app.utils.IDGenerate;
import io.renren.modules.sys.dao.SubsysDao;
import io.renren.modules.sys.entity.Subsys;
import io.renren.modules.sys.service.SubsysService;


@Service("subsysService")
public class SubsysServiceImpl extends ServiceImpl<SubsysDao, Subsys> implements SubsysService {

	@Override
	public Subsys saveSubSys(Subsys subsys) {
		if(subsys == null || StringUtils.isEmpty(subsys.getName()) || StringUtils.isEmpty(subsys.getCode())) {
			throw new BizException(Code.COODE_SYS_O1,"参数为空");
		}
		subsys.setCreater(ShiroUtils.getUserEntity().getUsername());
		subsys.setCreateUserId(ShiroUtils.getUserEntity().getUserId());
		subsys.setSysId(IDGenerate.getUUID32());
		subsys.setTenantId(ShiroUtils.getUserEntity().getTenantId());
		subsys.setCreateTime(System.currentTimeMillis());
		this.insert(subsys);
		 
		 return subsys;
	}

  
}
